#include <system/window_system.h>
#include <common_header.h>
#include <GLFW/glfw3.h>

namespace primal
{

	WindowSystem::WindowSystem()
	{
		glfwInit();
		glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
	}

	WindowSystem::~WindowSystem()
	{
		glfwTerminate();
	}

	Window WindowSystem::CreateWnd(const char* title, s32 width, s32 height, bool visibility)
	{
		glfwWindowHint(GLFW_VISIBLE, visibility ? GLFW_TRUE : GLFW_FALSE);
		return Window{ glfwCreateWindow(width,height,title,nullptr,nullptr) };
	}

	void WINDOW_DELETER::operator()(GLFWwindow* p) const noexcept
	{
		glfwDestroyWindow(p);
	}

	WindowSystem& GetWS()
	{
		static WindowSystem ws{};
		return ws;
	}
}